/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.hl7.v3.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.hl7.v3.PPDTS;
import org.hl7.v3.PQ;
import org.hl7.v3.ProbabilityDistributionType;
import org.hl7.v3.V3Package;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>PPDTS</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.hl7.v3.impl.PPDTSImpl#getStandardDeviation <em>Standard Deviation</em>}</li>
 *   <li>{@link org.hl7.v3.impl.PPDTSImpl#getDistributionType <em>Distribution Type</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PPDTSImpl extends TS1Impl implements PPDTS {
	/**
	 * The cached value of the '{@link #getStandardDeviation() <em>Standard Deviation</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStandardDeviation()
	 * @generated
	 * @ordered
	 */
	protected PQ standardDeviation;

	/**
	 * The default value of the '{@link #getDistributionType() <em>Distribution Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDistributionType()
	 * @generated
	 * @ordered
	 */
	protected static final ProbabilityDistributionType DISTRIBUTION_TYPE_EDEFAULT = ProbabilityDistributionType.G;

	/**
	 * The cached value of the '{@link #getDistributionType() <em>Distribution Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDistributionType()
	 * @generated
	 * @ordered
	 */
	protected ProbabilityDistributionType distributionType = DISTRIBUTION_TYPE_EDEFAULT;

	/**
	 * This is true if the Distribution Type attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean distributionTypeESet;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PPDTSImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return V3Package.eINSTANCE.getPPDTS();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PQ getStandardDeviation() {
		return standardDeviation;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetStandardDeviation(PQ newStandardDeviation, NotificationChain msgs) {
		PQ oldStandardDeviation = standardDeviation;
		standardDeviation = newStandardDeviation;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, V3Package.PPDTS__STANDARD_DEVIATION, oldStandardDeviation, newStandardDeviation);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStandardDeviation(PQ newStandardDeviation) {
		if (newStandardDeviation != standardDeviation) {
			NotificationChain msgs = null;
			if (standardDeviation != null)
				msgs = ((InternalEObject)standardDeviation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - V3Package.PPDTS__STANDARD_DEVIATION, null, msgs);
			if (newStandardDeviation != null)
				msgs = ((InternalEObject)newStandardDeviation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - V3Package.PPDTS__STANDARD_DEVIATION, null, msgs);
			msgs = basicSetStandardDeviation(newStandardDeviation, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.PPDTS__STANDARD_DEVIATION, newStandardDeviation, newStandardDeviation));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ProbabilityDistributionType getDistributionType() {
		return distributionType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDistributionType(ProbabilityDistributionType newDistributionType) {
		ProbabilityDistributionType oldDistributionType = distributionType;
		distributionType = newDistributionType == null ? DISTRIBUTION_TYPE_EDEFAULT : newDistributionType;
		boolean oldDistributionTypeESet = distributionTypeESet;
		distributionTypeESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.PPDTS__DISTRIBUTION_TYPE, oldDistributionType, distributionType, !oldDistributionTypeESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetDistributionType() {
		ProbabilityDistributionType oldDistributionType = distributionType;
		boolean oldDistributionTypeESet = distributionTypeESet;
		distributionType = DISTRIBUTION_TYPE_EDEFAULT;
		distributionTypeESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, V3Package.PPDTS__DISTRIBUTION_TYPE, oldDistributionType, DISTRIBUTION_TYPE_EDEFAULT, oldDistributionTypeESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetDistributionType() {
		return distributionTypeESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case V3Package.PPDTS__STANDARD_DEVIATION:
				return basicSetStandardDeviation(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case V3Package.PPDTS__STANDARD_DEVIATION:
				return getStandardDeviation();
			case V3Package.PPDTS__DISTRIBUTION_TYPE:
				return getDistributionType();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case V3Package.PPDTS__STANDARD_DEVIATION:
				setStandardDeviation((PQ)newValue);
				return;
			case V3Package.PPDTS__DISTRIBUTION_TYPE:
				setDistributionType((ProbabilityDistributionType)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case V3Package.PPDTS__STANDARD_DEVIATION:
				setStandardDeviation((PQ)null);
				return;
			case V3Package.PPDTS__DISTRIBUTION_TYPE:
				unsetDistributionType();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case V3Package.PPDTS__STANDARD_DEVIATION:
				return standardDeviation != null;
			case V3Package.PPDTS__DISTRIBUTION_TYPE:
				return isSetDistributionType();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (distributionType: ");
		if (distributionTypeESet) result.append(distributionType); else result.append("<unset>");
		result.append(')');
		return result.toString();
	}

} //PPDTSImpl
